/**
 * Handle changed data.
 *
 * @param {Object} oldValue old value
 * @param {Object} newValue new value
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"456B4DE5-BC1F-4E34-8942-DE81D895C208"}
 */
function onDataChangeImportes(oldValue, newValue, event) {
	if (importe < importe_pagado)
	{
		globals.gDialog('Aviso','El importe pagado es mayor al importe','OK')
		return false
	}
	saldo_mov = importe - importe_pagado
	return true
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"9572962D-789A-4853-AF30-4E16DB24B902"}
 */
function aceptar(event) {
	fecha_pago = new Date()
	databaseManager.saveData()
	databaseManager.setAutoSave(true)
	application.closeForm('DEUDA')
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"D3EDE71E-6E16-49BE-A8E7-8CD5C747B369"}
 */
function cancelar(event) {
	databaseManager.rollbackEditedRecords()
	databaseManager.setAutoSave(true)
	application.closeForm('DEUDA')
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"560D8CC0-61F1-453C-B50F-2C496681CB4C"}
 */
function onShow(firstShow, event) {
	databaseManager.setAutoSave(false)
	
	controller.newRecord()
	grupo_id = globals.gGrupo
	tipo_movim = 3
}
